extends Node

var monsters_array = []
const MONSTER_TRES_DICT = preload("res://src/monsters/monster_tres_dict.tres")
var monster_tscn = preload("res://src/monsters/card_monster_template.tscn")

@onready var player = get_tree().get_first_node_in_group("player")

static var MONSTER_GROUP_DICT = MONSTER_TRES_DICT.monster_group_dict;
static var MONSTER_DICT = MONSTER_TRES_DICT.monster_dict;
static var MONSTER_STATUE_DICT:Dictionary = MONSTER_TRES_DICT.monster_statue_dict

func _ready():
	MONSTER_TRES_DICT.load_monsters()
	

func delte_monster(monster_id):
	monsters_array[monster_id].queue_free()

func init_monster(node:Node):
	var monster:Monster = load("res://src/monsters/card_monster.tscn").instantiate()
	monster.stats = MonsterManager.MONSTER_DICT["M00"].duplicate()
	monster.set_global_position(Vector2(20,0) + player.get_global_position())
	monster.id = "G0";
	monsters_array.append(monster)
	node.add_child(monsters_array[0])


func generate_monster(key:String) -> Monster:
	var monster:Monster = monster_tscn.instantiate()
	monster.state = MonsterManager.MONSTER_DICT[key]
	#monster.add_to_group("monster")
	monster.init_state()
	return monster
	
